<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@ page import="commonj.sdo.DataObject"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@page import="com.eos.data.datacontext.UserObject"%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2014-10-31 14:12:31
  - Description:
-->
<head>
	<%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp"%>
	<title>我的待办</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <%
       UserObject userObject = (UserObject)request.getSession().getAttribute("userObject");
		DataObject capUser = (DataObject)userObject.get("capUser");
		// 登陆者所属BU
		String userId = userObject.getUserId();
     %>
</head>
<body>
	<div class="search-condition">
		<a href="#" class="searchclose"></a>
		<div class="list">
	        <div id="myDBProcessForm">
				<table style="width:100%;" class="table">
					<tr>
						<td class="tit" style="width:120px" align="right">
							摘要：
						</td>
						<td>
							<input id="processinstName" name="processinstName" class="nui-textbox" style="width:100%;" onEnter='onKeyEnter'/>
						<td class="tit" style="width:120px" align="right">
							任务节点：
						</td>
						<td>
							<input id="workitemName" name="workitemName" class="nui-textbox" style="width:100%;" onEnter='onKeyEnter'/>
						</td>
						<td style="width:20px"></td>
					</tr>
					<tr>
						<td class="tit" style="width:120px" align="right">
							流程产生时间：
						</td>
						<td colspan="4"> 
							<input id="startTime" name="startTime" class="nui-datepicker" allowInput="false" style="width:21%;" onEnter='onKeyEnter'/>
								~
							<input id="endTime" name="endTime" class="nui-datepicker" allowInput="false" style="width:20%;" onEnter='onKeyEnter'/>
						</td>
					</tr>
				</table> 
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="search-btn-area">
				  <tr>
				     <td>
				      	<a class="nui-button" iconCls="icon-search" onclick="search()">查询</a>&nbsp;&nbsp;
				      	<a class="nui-button" iconCls="icon-reload" onclick="clear()">清空</a>
				     </td>
				  </tr>
	          	</table>
	    	</div>
	  	</div>
	</div> 
	<div class="nui-fit"> 
	    <div id="myDBProcessGrid" class="nui-datagrid" style="width:100%;height:100%;" 
	   		 url="com.atozsoft.wf.processOperate.queryMyProcessList.biz.ext"  dataField="processList" pageSize="20" sortMode="client" multiSelect="false">
		    <div property="columns">
	            <div type="indexcolumn" align="center" headerAlign="center">序号</div>
	            <div field="PROCESSINSTNAME" headerAlign="center" allowSort="true" renderer="Itemclick" width="200px">
                	摘要
                </div>
                <div field="WORKITEMNAME" headerAlign="center" allowSort="true" width="150px">
                	任务节点
                </div>
                <div field="STARTTIME_TO" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">
                	任务到达时间
                </div>
                <div field="stopTime" headerAlign="center" allowSort="true" renderer="itname" width="100px">
               		任务滞留时间
                </div>
                <div field="CREATERNAME" headerAlign="center" allowSort="true" width="100px">
                	申请人
                </div>
                <div field="LASTNAME" headerAlign="center" allowSort="true" width="100px">
                	上一节点审批人
                </div>
                <div field="ACTIVITYDEFID" visible="false">流程节点定义ID</div>
		    </div>
		</div>
	</div>  
	<script type="text/javascript">
	    nui.parse();
	    
	    var form = new nui.Form("#myDBProcessForm");
	    var grid = nui.get("myDBProcessGrid");
	    var data = {currentstate:0};
	    grid.load({map:data});
    	
	    // 各种监听事件
        $(document).ready(
			function(){
			   //收起查询窗口
			   $(".search-condition-ex .searchclose").click(function(){
			  		$(".search-condition-ex .list").toggle();
					setTimeout("nui.layout()", 10 );
			   });
			}
		);
		
		// 项目名称链接
		function Itemclick(e){
	    	<%-- var record = e.record;
	        var workitemid = record.WORKITEMID;
	        var processInstId = record.PROCESSINSTID; 
	        var executeType = record.EXECUTETYPE; //用来标识是否为转发或者抄送
	        var castatus = record.CASTATUS;  //用来标识是否为加审
	        var dataType = ""; //判断数据类型是转发、加审
	        if("1" == executeType) {
	          dataType = "forward-" + record.TRANSMITID +"-"+ record.PCTCREATER; //数据是转发
	        }else if(castatus != null){   
	          dataType = "addApprove-" + record.ADDAPPROVEID +"-"+ record.CACREATER; //数据是加审  
	        }
	        //页面操作按钮加载(加载状态分：webType  阅读：read；操作：operate；已完成：done)
	        var url = "<%=request.getContextPath()%>/wf/processOperate/process_Detail.jsp?webType=operate&workitemid=" + workitemid +"&processInstId=" + processInstId+"&dataType=" + dataType;
			var name = record.PROCESSINSTNAME;
			var showName = record.PROCESSCHNAME;
	        var s = '<a class="New_Button"  style="color:#00C" href="javascript:addtab(\''+url+'\',\''+showName+'\')">'+name+'</a>';                       
	        return s; --%>
	        var record = e.record;
	        var workitemid = record.WORKITEMID;
	        var processInstId = record.PROCESSINSTID; 
	        var activitydefid = record.ACTIVITYDEFID; //节点名字
	        var executeType = record.EXECUTETYPE; //用来标识是否为转发或者抄送
	        var castatus = record.CASTATUS;  //用来标识是否为加审
	        var id = record.KEYVALUE;
	        var dataType = ""; //判断数据类型是转发、加审
	        if("1" == executeType) {
	          dataType = "forward-" + record.TRANSMITID +"-"+ record.PCTCREATER; //数据是转发
	        }else if(castatus != null){   
	          dataType = "addApprove-" + record.ADDAPPROVEID +"-"+ record.CACREATER; //数据是加审  
	        }
	        //页面操作按钮加载(加载状态分：webType  阅读：read；操作：operate；已完成：done)
	        var url = "<%=request.getContextPath()%>/wf/processOperate/process_Detail.jsp?webType=operate&workitemid=" + workitemid +"&processInstId=" + processInstId+"&keyvalue="+id+"&dataType=" + dataType+"&activitydefid="+activitydefid;
			var name = record.PROCESSINSTNAME;
			var showName = record.PROCESSCHNAME;
	        var s = '<a class="New_Button"  style="color:#00C" href="javascript:addtab(\''+url+'\',\''+showName+'\')">'+name+'</a>';                       
	        return s;
		}

	    // 跳转,新增tab页
		function addtab(url,name) {
			window.parent.parent.addtabs(url, "流程审批", "myProcess");
		}
		
		// Enter事件
      	function onKeyEnter(){
      		search();
      	}
	    
	    // 查询
	    function search(){
	        var panel = new nui.Form("#myDBProcessForm"); 
		    var data = panel.getData(false,true); //获取待办的查询条件
		    data.currentstate = 0; 
		    var startTime = nui.get("startTime").getValue();
		    var endTime = nui.get("endTime").getValue();
		    data.createtimeStart = startTime.substring(0,10);
		    data.createtimeEnd = endTime.substring(0,10);
		    grid.load({map:data});
	    }
		
		// 清空
		function clear(){
			form.reset();
		}
	    
	    // 一览行数据字典显示相关
		function itname(e){
    		// 滞留时间计算
    		if(e.field=="stopTime"){
				var endTime = new Date();
				var startTime = new Date(e.row.STARTTIME_TO);
				var days = (endTime.getTime() - startTime.getTime()) / (1000 * 60 * 60 * 24);
				return Math.round(days*10)/10+"天";
			}
		}
	    
    </script>
</body>
</html>